﻿FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDIR /app
ENV ASPNETCORE_ENVIRONMENT=Production
EXPOSE 8888
VOLUME /app/adminlogs
VOLUME /app/wwwroot

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["WYD.Admin.WebApi/WYD.Admin.WebApi.csproj", "WYD.Admin.WebApi/"]
COPY ["WYD.ServiceCore/WYD.ServiceCore.csproj", "WYD.ServiceCore/"]
COPY ["WYD.Common/WYD.Common.csproj", "WYD.Common/"]
COPY ["WYD.Infrastructure/WYD.Infrastructure.csproj", "WYD.Infrastructure/"]
COPY ["WYD.Model/WYD.Model.csproj", "WYD.Model/"]
COPY ["WYD.Repository/WYD.Repository.csproj", "WYD.Repository/"]
COPY ["WYD.Service/WYD.Service.csproj", "WYD.Service/"]
RUN dotnet restore "WYD.Admin.WebApi/WYD.Admin.WebApi.csproj"
COPY . .
WORKDIR "/src/WYD.Admin.WebApi"
RUN dotnet build "./WYD.Admin.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./WYD.Admin.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WYD.Admin.WebApi.dll", ""]

USER root
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -y libfontconfig1